<?php

namespace App\Models\Api;

class ResumeCertificate extends ApiModel
{
    //表名
    protected $table = 'resume_certificate';

    const CREATED_AT = 'addtime';
    const UPDATED_AT = 'updatetime';

    protected $guarded = [];

    /**
     * The attributes that should be hidden for arrays.
     * 隐藏字段
     * @var array
     */
    protected $hidden = ['addtime', 'updatetime', 'uid',
        'resume_id'];

    /**
     * 要触发的所有关联关系(子类增删改更新父类updatetime)
     *
     * @var array
     */
    protected $touches = ['resume'];
    protected $appends = ['gettime_name'];

    /**
     * 技能所属简历
     */
    public function resume()
    {
        return $this->belongsTo(Resume::class, 'resume_id', 'id');
    }

    public function getGettimeNameAttribute()
    {
        return substr($this->attributes['gettime'], 0, 4) . '年';
    }
}
